<template>
  <el-dialog title="详情" width="1280px" :visible="value" @close="handleClose">
    <el-form inline>
      <el-form-item label="开单TC">{{ data.yiyaBillingMain.tc }}</el-form-item>
    </el-form>
    <el-table
      stripe
      border
      show-summary
      :summary-method="getSummaries"
      :data="data.yiyaItemBillingExtends"
    >
      <el-table-column
        label="项目名称"
        align="center"
        min-width="150"
        prop="itemName"
      ></el-table-column>
      <el-table-column label="牙位" align="center" min-width="120">
        <ct-modules
          v-model="scope.row.toothPosition"
          slot-scope="scope"
          disabled
        ></ct-modules>
      </el-table-column>
      <el-table-column
        label="医生"
        align="center"
        prop="doctor"
        min-width="100"
      ></el-table-column>
      <el-table-column
        label="单价（元）"
        align="center"
        prop="unitPrice"
        min-width="100"
      ></el-table-column>
      <el-table-column label="数量/单位" align="center">
        <template slot-scope="scope">
          {{ scope.row.count }} {{ scope.row.unit }}
        </template>
      </el-table-column>
      <el-table-column
        label="原价（元）"
        align="center"
        prop="originalPrice"
        min-width="100"
      ></el-table-column>
      <el-table-column
        label="折扣（%）"
        align="center"
        prop="discount"
        min-width="100"
      ></el-table-column>
      <el-table-column
        label="折后价格（元）"
        align="center"
        prop="projectReceivable"
        min-width="120"
      >
        <template slot-scope="scope">
          {{ scope.row.projectReceivable }}.00
        </template>
      </el-table-column>
      <el-table-column
        label="应收（元）"
        align="center"
        prop="projectReceivable"
        min-width="100"
      >
        <template slot-scope="scope">
          {{ scope.row.projectReceivable }}.00
        </template>
      </el-table-column>
      <el-table-column
        label="实收（元）"
        align="center"
        prop="paidInAmount"
        min-width="100"
      ></el-table-column>
      <el-table-column
        label="储值金划扣金额（元）"
        align="center"
        min-width="160"
        prop="petCardAmount"
      ></el-table-column>
      <el-table-column
        label="优惠抵扣金额（元）"
        align="center"
        min-width="150"
        prop="deductionAmount"
      ></el-table-column>
    </el-table>
  </el-dialog>
</template>

<script>
import CtModules from '@/components/yiya/CtModules'

export default {
  name: 'BillingProject',
  components: {
    CtModules,
  },
  model: {
    prop: 'value',
    event: 'close',
  },
  props: {
    value: {
      type: Boolean,
      default: false,
    },
    data: {
      type: Object,
      default: () => ({ yiyaBillingMain: {}, total: {} }),
    },
  },
  watch: {
    value(val) {
      if (val) {
        this.init()
      }
    },
  },
  methods: {
    handleClose() {
      this.$emit('close', false)
    },
    init() {},
    getSummaries(row) {
      return row.columns.map(({ label, property }) =>
        label === '数量/单位' ? '合计' : this.data.total[property] || ''
      )
    },
  },
}
</script>

<style scoped></style>
